const path = require('path');
const fs = require('fs');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1713321142687_2734';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.static = {
    prefix: '/public/',
    dir: path.join(appInfo.baseDir, 'app/public'),
  };

  config.mysql = {
    client: {
      host: '119.29.244.175',
      port: '3306',
      user: 'mtest',
      password: 'mtest',
      database: 'mtest',
    },
    app: true,
    agent: false,
  };

  config.cors = {
    origin: '*', // 允许所有跨域访问，或者使用函数动态返回 origin
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
    credentials: true, // 允许 Cookie 可以包含在请求中
  };
  config.multipart = {
    mode: 'file',
  };
  // Disable CSRF
  config.security = {
    csrf: {
      enable: false, // 禁用 CSRF 保护
    },
  };

  return {
    ...config,
    ...userConfig,
  };
};
